package com.cloud.transaction.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cloud.commonapi.model.Goods_info;
import com.cloud.transaction.dao.Goods_infoMapper;
import com.cloud.transaction.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 陈楚城
 * @date 2019/9/29 15:03
 */
@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    private Goods_infoMapper goods_infoMapper;

    @Override
    public int add(Goods_info goods_info) {
        return goods_infoMapper.insertSelective(goods_info);
    }

    @Override
    public List<Goods_info> selectgoodslist() {
        return goods_infoMapper.list();
    }

    @Override
    public IPage<Goods_info> selectPage(int page, int pagesize) throws RuntimeException {
        try {
            Page<Goods_info> p = new Page<>(page, pagesize);
            p.setRecords(goods_infoMapper.selectPageExt(p));
            return p;
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage());
        }
    }


    @Override
    public Goods_info selectgoodsbyId(Integer goodsId) {
        return goods_infoMapper.selectByPrimaryKey(goodsId);
    }

    @Override
    public List<Goods_info> selectgoodsbykeyword(String keyword) {
        return goods_infoMapper.selectbykeyword(keyword);
    }

    @Override
    public int updategoods(Goods_info goods_info) {
        return goods_infoMapper.updateByPrimaryKeySelective(goods_info);
    }

    @Override
    public int deletegoods(Integer goosId) {
        return goods_infoMapper.deletegoods(goosId);
    }

    @Override
    public List<Goods_info> listbyaccountId(Integer accountId) {
        return goods_infoMapper.listbyaccountId(accountId);
    }

    @Override
    public List<Goods_info> listbyorder(Integer accountId) {
        return goods_infoMapper.listbyorder(accountId);
    }
}
